<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        let arr = ['1',1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5, 6, 6, 7]
        let obj = {}
        console.log(obj[1])
        for (const item of arr) {
            if (obj[item]) {
                obj[item] += 1
            }else{
                obj[item] = 1
            }
        }
        console.log(obj)  
        
        // let obj = arr.reduce(function(acc,cur){         
        //    if(acc.hasOwnProperty(cur)) {
        //        acc[cur] += 1
        //    }else{
        //        acc[cur] = 1
        //    }
        //    return acc
        // },{})
        // console.log(obj)   

        // let obj2 = arr.reduce(function(acc,cur){         
        //    if(acc.has(cur)) {
        //       acc.set(cur,acc.get(cur)+1)
        //    }else{
        //       acc.set(cur,1)
        //    }
        //    return acc
        // },new Map())
        // console.log(obj2)      

    </script>
</body>

</html>